package com.dstation.service;

import com.dstation.dao.CoinOperatedInfoMapper;
import com.dstation.domain.OrderInfo;
import com.dstation.domain.SubscriptionPackageInfo;
import com.dstation.service.interf.ICoinService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class CoinServiceImpl implements ICoinService {

    @Resource
    private CoinOperatedInfoMapper coinOperatedInfoMapper;

    @Override
    public int addSubScriptionOfCoin(SubscriptionPackageInfo subscriptionPackageInfo) {
        return coinOperatedInfoMapper.insertSubScriptionOfCoin(subscriptionPackageInfo);
    }

    @Override
    public int addOrderInfo(OrderInfo orderInfo) {
        return coinOperatedInfoMapper.insertOrderInfo(orderInfo);
    }

    @Override
    public int alterOrderStatusByOrderNo(String out_trade_no, int status) {
        return coinOperatedInfoMapper.updateOrderStatusByOrderNo(out_trade_no, status);
    }

    @Override
    public int alterCoinNumByUserID(Long userId, double coinNum) {
        return coinOperatedInfoMapper.updateCoinNumByUserID(userId, coinNum);
    }

    @Override
    public OrderInfo findOrderByOrderNum(String out_trade_no) {
        return coinOperatedInfoMapper.selectOrderByOrderNum(out_trade_no);
    }
}
